package model;

import java.util.Timer;

/**
 * @author  megea
 */
public class Sensor extends Recognizable {

    /**
     * @uml.property  name="sensedvalue"
     * @uml.associationEnd
     */
    protected SensedValue sensedvalue;
    private Timer timer = new Timer("Sensor");
    private Source source;

    public Sensor(Source source, Integer refreshTime, Integer id) {
        super(id);
        setSource(source);
        this.sensedvalue = source.getValue();
        MessuresTaker myMessures = new MessuresTaker(this, source);
        timer.schedule(myMessures, 0, refreshTime);
    }

    public SensedValue getSensedValue(){
        return sensedvalue;
    }

    public void setSensedValue(SensedValue value) {
        this.sensedvalue = value;
    }

    /**
     * @uml.property  name="source"
     * @uml.associationEnd  inverse="sensor:model.Source"
     */


    /**
     * Getter of the property <tt>source</tt>
     * @return  Returns the source.
     * @uml.property  name="source"
     */
    public Source getSource() {
        return source;
    }

    /**
     * Setter of the property <tt>source</tt>
     * @param source  The source to set.
     * @uml.property  name="source"
     */
    private void setSource(Source source) {
        this.source = source;
    }

}

